import request from '@/utils/request'
import qs from 'qs'

export function login(username, password, validCode, deviceId) {
  return request({
    url: 'oauth/admin/login',
    method: 'post',
    data: qs.stringify({
      username,
      password,
      validCode,
      deviceId
    })
  })
}

export function logintoken(username, password, validCode, deviceId, grant_type, scope, client_id, client_secret) {
  return request({
    url: 'api-auth/oauth/token',
    method: 'post',
    data: qs.stringify({
      username,
      password,
      validCode,
      deviceId,
      grant_type,
      scope,
      client_id,
      client_secret
    })
  })
}

export function logintokenfast(username, password, validCode, deviceId, grant_type, scope, client_id, client_secret) {
  return request({
    url: 'oauth/token',
    method: 'post',
    data: qs.stringify({
      username,
      password,
      validCode,
      deviceId,
      grant_type,
      scope,
      client_id,
      client_secret
    })
  })
}

export function getInfo() {
  return request({
    url: 'oauth/userinfo',
    method: 'post'
  })
}

export function getCodeImg() {
  return request({
    url: 'auth/vCode',
    method: 'get'
  })
}

